home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume1 / gr < prev    next >
Encoding:
Internet Message Format  |  1987-04-22  |  47.0 KB

  1. Path: seismo!ut-sally!husc6!mit-eddie!uw-beaver!tektronix!tekgen!tekred!games-request
  2. From: games-request@tekred.TEK.COM
  3. Newsgroups: mod.sources.games
  4. Subject: v01i006:  gr - games regulator
  5. Message-ID: <1108@tekred.TEK.COM>
  6. Date: 22 Apr 87 17:16:56 GMT
  7. Sender: billr@tekred.TEK.COM
  8. Lines: 1812
  9. Approved: billr@tekred.TEK.COM
  10.  
  11. Submitted by: Michael A. Cooper <mcooper@oberon.USC.EDU>
  12. Mod.sources.games: Volume 1, Issue 6
  13. Archive-name: gr
  14.  
  15.     [This is an update of a program originally posted to mod.sources
  16.      volume 1 issue 113 (May 1896).  While this isn't a game, it is
  17.      for game administrators, so I think it's appropriate for this
  18.      newsgroup.  I haven't used this [we just turn off r-x permission
  19.      on /usr/games with cron], but Mike welcomes comments (see README).
  20.         -br]
  21.  
  22. #! /bin/sh
  23. # This is a shell archive.  Remove anything before this line, then unpack
  24. # it by saving it into a file and typing "sh file".  To overwrite existing
  25. # files, type "sh file -c".  You can also feed this as standard input via
  26. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  27. # will see the following message at the end:
  28. #        "End of archive 1 (of 1)."
  29. # Contents:  README MANIFEST Makefile dolink.sh gr.8 gr.c gr.conf
  30. #   gr.conf.5 gr.h logfile.c parse.c
  31. # Wrapped by billr@tekred on Wed Apr 22 09:43:33 1987
  32. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  33. if test -f README -a "${1}" != "-c" ; then 
  34.   echo shar: Will not over-write existing file \"README\"
  35. else
  36. echo shar: Extracting \"README\" \(3571 characters\)
  37. sed "s/^X//" >README <<'END_OF_README'
  38. X
  39. X        G R  -  A   G A M E   R E G U L A T O R
  40. X
  41. X               for Berkeley UNIX
  42. X
  43. X                  Release 2.0
  44. X                 January, 1987
  45. X
  46. X
  47. XGR is used to regulate game playing.  It checks various system facts
  48. Xto determine if game playing is allowed.  GR can be set up to not
  49. Xallow game playing:
  50. X
  51. X    1) during certain hours (i.e. prime time work hours), 
  52. X    2) when the load average exceeds a set maximum, 
  53. X    3) the number of users exceeds a set maximum, 
  54. X    4) if there are not enough free "special" tty lines 
  55. X       (i.e. dialup lines), and 
  56. X    5) if a master no-game-playing file is present.  
  57. X
  58. XAll configuration parameters can be specified in a central control
  59. Xfile that is read on the fly.  Please read the manual pages (gr.8 and
  60. Xgr.conf.5) for specific details.
  61. X    
  62. XGR is based on "gsh" written at Reed College by a person who wishes to
  63. Xremain anonymous.  Little of the original code remains, however.
  64. X
  65. XWe have been running GR on VAX 11/750's (under both 4.2 and 4.3 BSD)
  66. Xfor almost a year now without any major problems.  It is very useful
  67. Xfor keeping people from abusing the system with games during heavy
  68. Xusage times when ``real'' work is being done.
  69. X
  70. XSince its last release via mod.sources in May of 1986, there have been
  71. Xseveral key bug fixes.  The most important of which, was a problem
  72. Xwith setuid games not being nuked off as advertised.  I have also
  73. Xmoved almost all configuration parameters to the master control file.
  74. XYou should no longer need to edit gr.h.  See the code for details on
  75. Xthe changes that have been made.
  76. X
  77. XThroughout the code you may notice #ifdef FINDTTY's.  This is there
  78. Xfor finding a user's real tty by looking at there process tree.  It
  79. Xwas written for 4.2BSD, but is not needed for 4.3BSD since the
  80. Xttyname() call now handles things properly.  You should not really
  81. Xneed the code if you are still running 4.2BSD.  Indeed, the version of
  82. XGR posted in mod.sources did not have the code and things seemed to
  83. Xwork okay without it.  If you *really* want to use it, please contact
  84. Xme and I will send you an additional C file containing the findtty()
  85. Xfunction itself.
  86. X
  87. X
  88. X
  89. X            How To Install GR
  90. X
  91. X
  92. XTo install GR: 
  93. X    1) First read the manual pages, gr.conf.5 and gr.8.  They
  94. X       contain specific information on how GR works and how it 
  95. X       should be configured.
  96. X    2) Edit Makefile to reflect how you wish to install GR.
  97. X       You will need to decide what user id GR will run as.
  98. X       I *strongly* suggest using "daemon" since all of the
  99. X       setuid games distributed with 4.[23]BSD run as "daemon".
  100. X       Unless GR is run as "daemon", it will not be able to kill
  101. X       off these setuid games.  The only other alternative is 
  102. X       making it setuid "root", but I strongly advise against this.
  103. X       If /dev/kmem is not readable by the world, but is readable
  104. X       by a particular group (4.3BSD uses group "kmem"), then set
  105. X       the group GR will run as to this group.
  106. X    3) Edit the provided "gr.conf" file to customize for your site.
  107. X    4) Type "make gr" to compile GR.
  108. X    5) Type "make create" to create the appropriate directory and
  109. X       files.  Do this only *once*!
  110. X    6) Run "make dolink" to have the games listed in Makefile
  111. X       put under control of the GR.
  112. X
  113. X
  114. X
  115. X
  116. X
  117. XIf you encounter any problems, please let me know.  I'm interested in
  118. Xhearing about your successes and failures with GR.  If you find a bug
  119. Xand fix it, please send a context diff along with a note explaining
  120. Xthe problem and your fix.
  121. X
  122. X
  123. XMichael A. Cooper, University Computing Services, U of Southern California
  124. X  UUCP: {sdcrdcf, uscvax}!oberon!mcooper  BITNET: mcooper@uscvaxq
  125. X  ARPA: mcooper@oberon.USC.EDU            PHONE: (213) 743-3462
  126. END_OF_README
  127. if test 3571 -ne `wc -c <README`; then
  128.     echo shar: \"README\" unpacked with wrong size!
  129. fi
  130. # end of overwriting check
  131. fi
  132. if test -f MANIFEST -a "${1}" != "-c" ; then 
  133.   echo shar: Will not over-write existing file \"MANIFEST\"
  134. else
  135. echo shar: Extracting \"MANIFEST\" \(444 characters\)
  136. sed "s/^X//" >MANIFEST <<'END_OF_MANIFEST'
  137. X   File Name        Archive #    Description
  138. X-----------------------------------------------------------
  139. X MANIFEST                  1    This shipping list
  140. X Makefile                  1    
  141. X README                    1    
  142. X dolink.sh                 1    
  143. X gr.8                      1    
  144. X gr.c                      1    
  145. X gr.conf                   1    
  146. X gr.conf.5                 1    
  147. X gr.h                      1    
  148. X logfile.c                 1    
  149. X parse.c                   1    
  150. END_OF_MANIFEST
  151. if test 444 -ne `wc -c <MANIFEST`; then
  152.     echo shar: \"MANIFEST\" unpacked with wrong size!
  153. fi
  154. # end of overwriting check
  155. fi
  156. if test -f Makefile -a "${1}" != "-c" ; then 
  157.   echo shar: Will not over-write existing file \"Makefile\"
  158. else
  159. echo shar: Extracting \"Makefile\" \(2256 characters\)
  160. sed "s/^X//" >Makefile <<'END_OF_Makefile'
  161. X#
  162. X# $Header: Makefile,v 1.10 86/12/17 19:36:12 mcooper Exp $
  163. X#
  164. X# Makefile for Game Regulator.
  165. X#
  166. X
  167. X#
  168. X# GAMEDIR - This is where the symbolic links are to be placed.
  169. X#        Should be /usr/games.
  170. X#
  171. XGAMEDIR = /usr/games
  172. X
  173. X#
  174. X# HIDEDIR - Name of directory to hide the actual executables
  175. X#
  176. XHIDEDIR = $(GAMEDIR)/.hide
  177. X
  178. X#
  179. X# MAN5 - Manual directory for gr.conf.5
  180. X# MAN8 - Manual directory for gr.8
  181. X#
  182. XMAN5 = /usr/usc/man/man5
  183. XMAN5 = /usr/usc/man/man8
  184. X
  185. X# 
  186. X# OWNER - This is the user who owns HIDEDIR.
  187. X# GROUP - This group has read/execute permissions on HIDEDIR and owns
  188. X#      the Game Regulator which is set[ug]id to OWNER/GROUP.
  189. X#      Either the owner or the group must have read access to
  190. X#      /dev/kmem.
  191. X#
  192. XOWNER = daemon
  193. XGROUP = kmem
  194. X
  195. X#
  196. X# NAME - Name of Game Regulator in GAMEDIR.  I have it set to ".gr"
  197. X#      so it doesn't show up with ls(1) by default.
  198. X#
  199. XNAME = .gr
  200. X
  201. X#
  202. X# GAMES - The games in the original GAMEDIR to be put under regulation.
  203. X#      Currently set to the games distributed with 4.3BSD.
  204. X#
  205. XGAMES = aardvark adventure arithmetic backgammon battlestar bcd\
  206. X    bogdict boggle btlgammon canfield chess ching cribbage\
  207. X    doctor factor fish hangman hunt mille rain robots rogue\
  208. X    sail snake teachgammon trek worm worms wump zork
  209. X
  210. XCFLAGS = -O
  211. X
  212. XOBJS = gr.o logfile.o parse.o
  213. XSRCS = gr.c gr.h logfile.c parse.c
  214. X
  215. Xgr: $(OBJS)
  216. X    cc $(OBJS) -o gr
  217. X
  218. X#
  219. X# Set "CFLAGS=-DDEBUG" if you want gr compiled with debug info.
  220. X#
  221. Xdebug: $(OBJS)
  222. X    cc -g $(OBJS) -o gr
  223. X    rm -f gr
  224. X    ln -s gr debug
  225. X
  226. X.c.o:
  227. X    cc $(CFLAGS) -c $*.c
  228. X
  229. X$(OBJS): gr.h
  230. X
  231. Xinstall: gr gr.conf.5 gr.8
  232. X    install -m 6751 -o $(OWNER) -g $(GROUP) gr $(GAMEDIR)/$(NAME)
  233. X    install -c gr.conf.5 $(MAN5)
  234. X    install -c gr.8 $(MAN8)
  235. X
  236. Xcreate:
  237. X    -mkdir $(HIDEDIR)
  238. X    chown $(OWNER) $(HIDEDIR)
  239. X    chgrp $(GROUP) $(HIDEDIR)
  240. X    chmod 770 $(HIDEDIR)
  241. X    cp gr.conf $(GAMEDIR)/lib
  242. X    touch $(GAMEDIR)/lib/gr.log
  243. X    chown $(OWNER) $(GAMEDIR)/lib/gr.conf $(GAMEDIR)/lib/gr.log
  244. X    chgrp $(GROUP) $(GAMEDIR)/lib/gr.conf $(GAMEDIR)/lib/gr.log
  245. X    chmod 664 $(GAMEDIR)/lib/gr.conf $(GAMEDIR)/lib/gr.log
  246. X
  247. Xdolink: dolink.sh
  248. X    sed -e s#HIDEDIR#$(HIDEDIR)# -e s#GAMEDIR#$(GAMEDIR)# \
  249. X        -e s#NAME#$(NAME)# dolink.sh > dolink
  250. X    chmod +x dolink
  251. X    dolink $(GAMES)
  252. X
  253. Xclean:
  254. X    rm -f *.o log dolink gr.shar debug
  255. X
  256. Xshar:
  257. X    shar README gr.8 gr.conf.5 Makefile gr.conf $(SRCS) dolink.sh > gr.shar
  258. END_OF_Makefile
  259. if test 2256 -ne `wc -c <Makefile`; then
  260.     echo shar: \"Makefile\" unpacked with wrong size!
  261. fi
  262. # end of overwriting check
  263. fi
  264. if test -f dolink.sh -a "${1}" != "-c" ; then 
  265.   echo shar: Will not over-write existing file \"dolink.sh\"
  266. else
  267. echo shar: Extracting \"dolink.sh\" \(203 characters\)
  268. sed "s/^X//" >dolink.sh <<'END_OF_dolink.sh'
  269. X#!/bin/csh -f
  270. X#
  271. X# dolink - Move and link files for GR.
  272. X#
  273. X# **** Do NOT edit this file - it is automatically generated ****
  274. X#
  275. Xcd GAMEDIR
  276. Xforeach i ($*)
  277. X    echo Doing $i...
  278. X    mv $i HIDEDIR
  279. X    ln -s NAME $i
  280. Xend
  281. END_OF_dolink.sh
  282. if test 203 -ne `wc -c <dolink.sh`; then
  283.     echo shar: \"dolink.sh\" unpacked with wrong size!
  284. fi
  285. # end of overwriting check
  286. fi
  287. if test -f gr.8 -a "${1}" != "-c" ; then 
  288.   echo shar: Will not over-write existing file \"gr.8\"
  289. else
  290. echo shar: Extracting \"gr.8\" \(3107 characters\)
  291. sed "s/^X//" >gr.8 <<'END_OF_gr.8'
  292. X.\"
  293. X.\" $Header: gr.8,v 1.1 86/12/17 19:31:25 mcooper Exp $
  294. X.\"
  295. X.TH GR 8 12/17/86
  296. X.ds ]W USC Computing Services
  297. X.SH NAME
  298. Xgr \- Game Regulator
  299. X.SH SYNOPSIS
  300. Xln -s
  301. X.B GR
  302. X.I game    
  303. X\- To install the
  304. X.B GR
  305. X.SH DESCRIPTION
  306. X.I GR
  307. Xis a program used to regulate game playing.
  308. XWhen invoked, 
  309. X.I GR
  310. Xlooks at the name it was called by (argv[0]) and assumes that is the name
  311. Xof the game that is to be played.
  312. XThe actual binaries are located in a ``hidden'' directory (usually
  313. X.B /usr/games/.hide).
  314. XBefore an actual game is started, 
  315. X.I GR
  316. Xdetermines several system facts.
  317. X.PP
  318. XThe file
  319. X.B /usr/games/lib/gr.conf
  320. Xis the configuration and control file for
  321. Xthe
  322. X.I GR.
  323. XIt
  324. Xis checked to determine: 1) the maximum load average, 2) the maximum
  325. Xnumber of users, for game playing to be allowed, and 3)
  326. Xthe priority (see 
  327. X.I setpriority(2))
  328. Xthe game will run at.
  329. XThere are also some configuration parameters that you may set.
  330. XSee the manual on
  331. X.I gr.conf(5)
  332. Xfor details.
  333. X.PP
  334. XIf the initial system conditions are satisfactory, then the requested game
  335. Xis forked (via 
  336. X.I fork(2))
  337. Xand  the
  338. X.I GR
  339. Xgoes into a loop where it sleeps for an interval and
  340. Xthen wakes up 
  341. Xand checks the current time, number of users, the load average and
  342. Xif the 
  343. X.I nogames
  344. Xfile is present (see below).  If any of these conditions is unsatisfactory, an
  345. Xappropriate message is printed and the user is warned to end their game.
  346. XThe user is given a total of three warnings (with an appropriate interval 
  347. Xin-between warnings to act) before the game is actually killed.
  348. X.PP
  349. XThe file
  350. X.B /usr/games/nogames
  351. Xcan be used to ``turn off'' game playing.  The first line of the file is
  352. Xused as part of a message that is displayed to the user.
  353. XUseful for turning off game playing for one reason or another.
  354. X.SH AUTHOR
  355. XMichael A. Cooper (mcooper@oberon.USC.EDU)
  356. X.br
  357. XUSC Computing Services
  358. X.SH FILES
  359. X.nf
  360. X.ta \w'/usr/games/lib/gr.conf 'u
  361. X/usr/games/lib/gr.conf    - Master configuration file
  362. X/usr/games/lib/gr.log    - Log file 
  363. X/usr/games/.hide    - Directory of ``real'' binaries
  364. X/usr/games/nogames    - Turn off game playing
  365. X.SH SEE ALSO
  366. Xgr.conf(5), fork(2), kill(2), setpriority(2),
  367. X.br
  368. XSection 6 of the UNIX Programmer's Manual.
  369. X.SH DIAGNOSTICS
  370. X.IP "Game playing is not permitted on tty?? at any time."
  371. XThe installer of the 
  372. X.I GR
  373. Xspecified tty ``??'' as a tty on which game playing is 
  374. X.I never
  375. Xpermitted.
  376. X.IP "The system load is greater than \fIN\fR."
  377. XThe load average exceeds the limit of ``\fIN\fR'' for the requested
  378. Xgame.
  379. X.IP "There are more than \fIN\fR users logged in."
  380. XThe number of users exceeds the limit of ``\fIN\fR'' for the requested
  381. Xgame.
  382. X.IP "Game playing is not permitted between \fIM\fR and \fIN\fR hours on weekdays."
  383. XThe installer of the
  384. X.I GR
  385. Xhas specified that game playing is not permitted between the hours of
  386. X.I M
  387. Xand 
  388. X.I N
  389. Xduring weekdays.
  390. X.IP "There are not \fIN\fR \fIspecial\fR ttys available."
  391. XThe installer of the
  392. X.I GR
  393. Xhas specified that there must be at least 
  394. X.I N
  395. Xspare 
  396. X.I special
  397. Xttys available for game playing to be permitted.
  398. X.SH BUGS
  399. XThere are several ways to play games on  
  400. X.I special
  401. Xttys no matter the number of
  402. X.I special
  403. Xttys in use.
  404. END_OF_gr.8
  405. if test 3107 -ne `wc -c <gr.8`; then
  406.     echo shar: \"gr.8\" unpacked with wrong size!
  407. fi
  408. # end of overwriting check
  409. fi
  410. if test -f gr.c -a "${1}" != "-c" ; then 
  411.   echo shar: Will not over-write existing file \"gr.c\"
  412. else
  413. echo shar: Extracting \"gr.c\" \(16592 characters\)
  414. sed "s/^X//" >gr.c <<'END_OF_gr.c'
  415. X/*
  416. X *                  GR - A  G A M E   R E G U L A T O R
  417. X *                          for Berkeley UNIX
  418. X *
  419. X */
  420. X
  421. X#ifndef lint
  422. Xstatic char *RCSid = "$Header: gr.c,v 1.32 86/12/02 20:26:57 mcooper Locked $";
  423. X#endif
  424. X
  425. X/*
  426. X *------------------------------------------------------------------
  427. X *
  428. X * $Source: /big/src/usc/bin/gr/RCS/gr.c,v $
  429. X * $Revision: 1.32 $
  430. X * $Date: 86/12/02 20:26:57 $
  431. X * $State: Exp $
  432. X * $Author: mcooper $
  433. X * $Locker: mcooper $
  434. X *
  435. X *------------------------------------------------------------------
  436. X *
  437. X * Michael A. Cooper (mcooper@oberon.USC.EDU)
  438. X * University Computing Services,
  439. X * University of Southern California
  440. X *
  441. X *------------------------------------------------------------------
  442. X * $Log:    gr.c,v $
  443. X * Revision 1.32  86/12/02  20:26:57  mcooper
  444. X * #ifdef'd all dprintf's.
  445. X * 
  446. X * Revision 1.31  86/08/06  20:07:55  mcooper
  447. X * Yet another attempt at fixing the setuid
  448. X * problem.  Think I got it this time!
  449. X * 
  450. X * Revision 1.30  86/08/05  12:54:22  mcooper
  451. X * Fixed setuid() problem (again).
  452. X * 
  453. X * Revision 1.29  86/07/30  12:22:30  mcooper
  454. X * If DEBUG is defined, use a SLEEPTIME of 5
  455. X * to speed things up.
  456. X * 
  457. X * Revision 1.28  86/07/17  16:13:04  mcooper
  458. X * All fatal errors now use fatal().
  459. X * 
  460. X * Revision 1.27  86/07/17  14:49:21  mcooper
  461. X * - Fixed bug in freettys() that caused
  462. X *   was_freettys to be TRUE when there
  463. X *   where exactly cf->cf_nofreettys free.
  464. X * - Tweaked was_freettys user message a bit.
  465. X * 
  466. X * Revision 1.26  86/07/15  14:53:36  mcooper
  467. X * Determine user name in setup() instead of
  468. X * everytime logfile() is called.
  469. X * 
  470. X * Revision 1.25  86/07/14  19:03:45  mcooper
  471. X * Log more info to a log file.
  472. X * 
  473. X * Revision 1.24  86/07/14  15:53:53  mcooper
  474. X * Moved most of the compile time configuration
  475. X * options to the control file.
  476. X * 
  477. X * Revision 1.23  86/07/03  15:54:41  mcooper
  478. X * Now checks for NOGAMING file along with the
  479. X * other tests in case game playing is turn off
  480. X * while we're playing.
  481. X * 
  482. X * Revision 1.22  86/07/03  14:25:07  mcooper
  483. X * - Major work on "special" ttys.  
  484. X *   - Bug fix in deltty().
  485. X *   - Changed are #define macros.
  486. X *   - Added findtty() (in findtty.c) to try and
  487. X *     determine the users real tty.  (4.2bsd)
  488. X * - Added debug mode.
  489. X * - Misc. - Can't remember them all.
  490. X * 
  491. X * Revision 1.21  86/06/18  13:46:47  mcooper
  492. X * Implemented BAD_TTYS - Check to see if
  493. X * the user is on a BAD_TTYS.  If so, game
  494. X * playing is not permited at all.  Also
  495. X * cleaned up #ifdef TOD stuff.
  496. X * 
  497. X * Revision 1.20  86/06/04  12:21:23  mcooper
  498. X * Use SP_NAME for name of special ttys when
  499. X * printing messages to the user.
  500. X * 
  501. X * Revision 1.19  86/06/02  13:31:53  mcooper
  502. X * More cleanup on SP_TTYS.
  503. X * 
  504. X * Revision 1.18  86/05/30  21:33:10  mcooper
  505. X * Added support for "special" ttys.  i.e. only a limited
  506. X * number of SP_TTYS.
  507. X * 
  508. X * Revision 1.17  86/05/14  16:08:44  mcooper
  509. X * Cleaned up and somewhat de-linted.
  510. X * 
  511. X *------------------------------------------------------------------
  512. X */
  513. X
  514. X#include <stdio.h>
  515. X#include <pwd.h>
  516. X#include <signal.h>
  517. X#include <sys/wait.h>
  518. X#include <sys/types.h>
  519. X#include <sys/stat.h>
  520. X#include <sys/time.h>
  521. X#include <sys/resource.h>
  522. X#include <sys/file.h>
  523. X#include <utmp.h>
  524. X#include <nlist.h>
  525. X
  526. X#include <sys/vm.h>
  527. X#include <machine/pte.h>
  528. X
  529. X#include "gr.h"
  530. X
  531. X#ifdef DEBUG
  532. Xint sleeptime = 5;
  533. X#else
  534. Xint sleeptime = SLEEPTIME;
  535. X#endif
  536. X
  537. Xint hastried = 0;
  538. X
  539. Xint Fswap;
  540. Xint Fpmem;
  541. Xint Fkmem;
  542. Xint Futmp;
  543. X
  544. Xchar *mytty;
  545. Xchar *user;
  546. Xchar *prog = "GR";
  547. X
  548. Xstatic char *badtty;
  549. X#ifdef FINDTTY
  550. Xstruct pte *usrptmap, *usrpt;    /* Hold values of _Usrptmap & _usrpt */
  551. Xint i_proc, i_nproc;            /* Hold values of _proc & _nproc */
  552. X#endif
  553. X
  554. Xint was_freettys;
  555. Xint was_badttys;
  556. Xint was_tod;
  557. Xint was_load;
  558. Xint was_nogames;
  559. Xint was_users;
  560. X
  561. Xstatic double avenrun[3];
  562. Xstatic char *game;
  563. Xchar mbuf[BUFSIZ];
  564. X
  565. X
  566. Xchar *warnmesg1 = "to save your game.  If you do not leave\r\nthe game ";
  567. Xchar *warnmesg2 = "within this period, your game will be terminated.";
  568. X
  569. Xchar *warntime[3] = {
  570. X    "4 minutes ",
  571. X    "2 minutes ",
  572. X    "1 minute "
  573. X};
  574. X
  575. X
  576. Xstatic struct utmp buf;
  577. Xstatic struct nlist nl[] = {
  578. X#define N_AVENRUN    0
  579. X    { "_avenrun" },
  580. X#ifdef FINDTTY
  581. X#define N_PROC        1                /* Address of process table */
  582. X    { "_proc" },
  583. X#define N_NPROC        2                /* Length of process table */
  584. X    { "_nproc" },
  585. X#define N_USRPTMAP     3
  586. X    { "_Usrptmap" },
  587. X#define N_USRPT     4
  588. X    { "_usrpt" },
  589. X#endif
  590. X    { "" },
  591. X};
  592. X
  593. Xchar *rindex();
  594. Xchar *deltty();
  595. Xchar *gettyname();
  596. Xchar *getaline();
  597. Xlong time();
  598. X
  599. Xint debug = 0;
  600. Xstruct cfinfo *cf, *parse();
  601. X
  602. X/*VARARGS*/
  603. Xmain(argc, argv)
  604. Xint argc;
  605. Xchar **argv;
  606. X{
  607. X    game = rindex(argv[0], '/');
  608. X    if (game == 0)
  609. X        game = argv[0];
  610. X    else
  611. X        game++;    /* Skip the '/' */
  612. X
  613. X    if (strcmp(game, "debug") == 0)
  614. X        debug = 1;
  615. X
  616. X    if (debug) {
  617. X        setbuf(stdout, 0);
  618. X#ifdef DEBUG
  619. X        dprintf("debug is ON\n");
  620. X#endif DEBUG
  621. X        sleeptime = 5;
  622. X    }
  623. X
  624. X    setup(game);
  625. X
  626. X    if (checkfor(cf->cf_nogames) || tod() || badttys() || freettys() || 
  627. X      users() || load()) {
  628. X        fprintf(stderr, "Sorry, no games now.\n");
  629. X        if (was_nogames)
  630. X            fprintf(stderr, getaline(cf->cf_nogames));
  631. X        if (was_freettys)
  632. X            fprintf(stderr, "There %s not %d %s tty%c available.\n",
  633. X                (cf->cf_nofreettys > 1) ? "are" : "is", cf->cf_nofreettys,
  634. X                cf->cf_spname, (cf->cf_nofreettys > 1) ? 's' : 0);
  635. X        if (was_badttys)
  636. X            fprintf(stderr, 
  637. X            "Game playing is not permitted on tty%s at any time.\n",
  638. X                badtty);
  639. X        if (was_load)
  640. X            fprintf(stderr, 
  641. X                "The system load is greater than %.2lf.\n",
  642. X                cf->cf_load);
  643. X        if (was_users)
  644. X            fprintf(stderr, 
  645. X                "There are more than %d users logged in.\n",
  646. X                cf->cf_users);
  647. X        if (was_tod)
  648. X            fprintf(stderr, 
  649. X"Game playing is not permitted between %d00 and %d00 hours on weekdays.\n", 
  650. X                cf->cf_todmorn, cf->cf_todeven);
  651. X        exit(1);
  652. X    }
  653. X    if (cf->cf_logfile[0]) {
  654. X        sprintf(mbuf, "startup of %s (%d)", game, getpid());
  655. X        logfile(mbuf, cf->cf_logfile);
  656. X    }
  657. X    play(game, argv);
  658. X}
  659. X
  660. Xplay(game, args)
  661. Xchar *game;
  662. Xchar **args;
  663. X{
  664. X    int pid;
  665. X    char tmp[BUFSIZ];
  666. X
  667. X    switch (pid = fork()) {
  668. X        case -1:
  669. X            fprintf(stderr, "Cannot fork.\n");
  670. X            exit(1);
  671. X        case 0:
  672. X            (void) strcpy(tmp, cf->cf_hidedir);
  673. X            (void) strcat(tmp, "/");
  674. X            (void) strcat(tmp, game);
  675. X            (void) signal(SIGINT, SIG_DFL);
  676. X            (void) signal(SIGQUIT, SIG_DFL);
  677. X            (void) signal(SIGTSTP, SIG_DFL);
  678. X#ifdef DEBUG
  679. X            dprintf("before: getuid = %d\n", getuid());
  680. X            dprintf("before: geteuid = %d\n", geteuid());
  681. X#endif DEBUG
  682. X            (void) setuid(getuid());
  683. X#ifdef DEBUG
  684. X            dprintf("after: getuid = %d\n", getuid());
  685. X            dprintf("after: geteuid = %d\n", geteuid());
  686. X#endif DEBUG
  687. X            if(setpriority(PRIO_PROCESS, 0, cf->cf_priority) < 0) {
  688. X                fatal("setpriority", TRUE);
  689. X                /*NOTREACHED*/
  690. X            }
  691. X            execv(tmp, args);
  692. X            fatal(tmp, TRUE);
  693. X            /*NOTREACHED*/
  694. X    }
  695. X    for (;;) {
  696. X        sleep(sleeptime);
  697. X        if (load() || checkfor(cf->cf_nogames) || tod() || freettys() || 
  698. X          users()) {
  699. X            warn(0);
  700. X            sleep(sleeptime);
  701. X            if (reprieve())
  702. X                continue;
  703. X            sleep(sleeptime);
  704. X            if (reprieve())
  705. X                continue;
  706. X            warn(1);
  707. X            sleep(sleeptime);
  708. X            if (reprieve())
  709. X                continue;
  710. X            warn(2);
  711. X            sleep(sleeptime);
  712. X            if (reprieve())
  713. X                continue;
  714. X            blast(pid);
  715. X        }
  716. X    }
  717. X}
  718. X
  719. Xreprieve()
  720. X{
  721. X    static char mess[] = "\r\nYou have a reprieve.  Continue playing.\r\n";
  722. X
  723. X    if (checkfor(cf->cf_nogames) || load() || tod() || freettys() || users())
  724. X        return (0);
  725. X    (void) write(2, mess, sizeof(mess));
  726. X    return (1);
  727. X}
  728. X
  729. X/*
  730. X * warn - Warn the user how close his game is to ending.
  731. X */
  732. Xwarn(which)
  733. Xint which;
  734. X{
  735. X    char buf1[BUFSIZ];
  736. X    char buf2[BUFSIZ];
  737. X    char *space = "                                                        ";
  738. X    extern errno;
  739. X
  740. X#ifdef DEBUG
  741. X    dprintf("warn(): which = %d\n", which);
  742. X#endif DEBUG
  743. X
  744. X    if (was_nogames)
  745. X        (void) sprintf(buf2, getaline(cf->cf_nogames));
  746. X    if (was_load)
  747. X        (void) sprintf(buf2, 
  748. X            "The system load is greater than %.2lf.",
  749. X            cf->cf_load);
  750. X    if (was_users)
  751. X        (void) sprintf(buf2, 
  752. X            "There are more than %d users logged in.",
  753. X                cf->cf_users);
  754. X    if (was_freettys)
  755. X        (void) sprintf(buf2, "There %s not %d %s tty%s available.",
  756. X            (cf->cf_nofreettys > 1) ? "are" : "is", cf->cf_nofreettys,
  757. X            cf->cf_spname, (cf->cf_nofreettys > 1) ? "s" : "");
  758. X    if (was_tod)
  759. X        (void) sprintf(buf2, "Game time is over.");
  760. X
  761. X    (void) sprintf(buf1, 
  762. X            "\r\n\007\007\007%s\r\n%s\r\nYou have %s%s%s\r\n%s\r\n",
  763. X            space, buf2, warntime[which], warnmesg1, warnmesg2, space);
  764. X    (void) write(2, buf1, strlen(buf1));
  765. X}
  766. X
  767. X/*
  768. X * blast - Kill the game.
  769. X */
  770. Xblast(pid)
  771. Xint pid;
  772. X{
  773. X    static char mess[] = "\rYour game is forfeit.\r\n";
  774. X
  775. X#ifdef DEBUG
  776. X    dprintf("blast(): pid = %d myuid = %d(%d)\n", pid, getuid(), geteuid());
  777. X#endif DEBUG
  778. X
  779. X    if(!hastried)
  780. X        (void) write(2, mess, sizeof(mess));
  781. X
  782. X    if (cf->cf_logfile[0]) {
  783. X        (void) sprintf(mbuf, "blast(%d) %s", pid, game);
  784. X        (void) logfile(mbuf, cf->cf_logfile);
  785. X    }
  786. X
  787. X    if(kill(pid, SIGHUP) < 0) {
  788. X        (void) sprintf(mbuf, "kill(%d, SIGHUP) failed: %d", pid, errno);
  789. X        (void) logfile(mbuf, cf->cf_logfile);
  790. X#ifdef DEBUG
  791. X        dprintf("%s: ", mbuf);
  792. X        if(debug)perror();
  793. X#endif DEBUG
  794. X    }
  795. X    sleep(30);
  796. X    if(kill(pid, SIGKILL) < 0) {
  797. X        (void) sprintf(mbuf, "kill(%d, SIGKILL) failed: %d", pid, errno);
  798. X        (void) logfile(mbuf, cf->cf_logfile);
  799. X#ifdef DEBUG
  800. X        dprintf("%s: ", mbuf);
  801. X        if(debug)perror();
  802. X#endif DEBUG
  803. X    }
  804. X    if(!hastried) {
  805. X#ifdef DEBUG
  806. X        dprintf("_before: getuid = %d\n", getuid());
  807. X        dprintf("_before: geteuid = %d\n", geteuid());
  808. X#endif DEBUG
  809. X        (void) setuid(getuid());
  810. X#ifdef DEBUG
  811. X        dprintf("_after: getuid = %d\n", getuid());
  812. X        dprintf("_after: geteuid = %d\n", geteuid());
  813. X#endif DEBUG
  814. X        hastried = 1;
  815. X        blast(pid);
  816. X        return;
  817. X    } else
  818. X        hastried = 0;
  819. X}
  820. X
  821. X/*
  822. X * death - More on killing.
  823. X */
  824. Xdeath()
  825. X{
  826. X    union wait status;
  827. X
  828. X    if (wait3(&status, WNOHANG | WUNTRACED, (char *)0) == 0) {
  829. X        return;
  830. X    }
  831. X    if (status.w_stopval == WSTOPPED) {
  832. X        (void) signal(SIGTSTP, SIG_DFL);
  833. X        (void) kill(getpid(), SIGTSTP);
  834. X        (void) signal(SIGTSTP, SIG_IGN);
  835. X        return;
  836. X    } else {
  837. X#ifdef DEBUG
  838. X        dprintf("\nClosing with exit(0)...\n");
  839. X#endif DEBUG
  840. X        if(cf->cf_logfile[0]) {
  841. X            (void) sprintf(mbuf, "end of %s (%d)", game, getpid());
  842. X            (void) logfile(mbuf, cf->cf_logfile);
  843. X        }
  844. X        (void) close(Fkmem);
  845. X        (void) close(Fpmem);
  846. X        (void) close(Fswap);
  847. X        (void) close(Futmp);
  848. X        exit(0);
  849. X    }
  850. X}
  851. X
  852. X/*
  853. X * setup - Setup constants.
  854. X */
  855. Xsetup(game)
  856. Xchar *game;
  857. X{
  858. X    FILE *list;
  859. X    char *getlogin();
  860. X    struct passwd *pw, *getpwuid();
  861. X
  862. X    Fswap = Fpmem = Fkmem = Futmp = 0;
  863. X
  864. X    if ((Futmp = open("/etc/utmp", 0)) < 0) {
  865. X        fatal("/etc/utmp", TRUE);
  866. X        /*NOTREACHED*/
  867. X    }
  868. X    if ((Fkmem = open("/dev/kmem", 0)) < 0) {
  869. X        fatal("/dev/kmem", TRUE);
  870. X        /*NOTREACHED*/
  871. X    }
  872. X    if ((Fpmem = open("/dev/mem", 0)) < 0) {
  873. X        fatal("/dev/mem", TRUE);
  874. X        /*NOTREACHED*/
  875. X    }
  876. X    if ((Fswap = open("/dev/drum", 0)) < 0) {
  877. X        fatal("/dev/drum", TRUE);
  878. X        /*NOTREACHED*/
  879. X    }
  880. X
  881. X    nlist("/vmunix", nl);
  882. X    if (nl[0].n_type == 0) {
  883. X        fatal("/vmunix", TRUE);
  884. X        /*NOTREACHED*/
  885. X    }
  886. X
  887. X#ifdef FINDTTY
  888. X    usrptmap = (struct pte *) nl[N_USRPTMAP].n_value;
  889. X    usrpt = (struct pte *) nl[N_USRPT].n_value;
  890. X
  891. X#ifdef DEBUG
  892. X    dprintf("seeking _nproc...\n");
  893. X#endif DEBUG
  894. X    memseek(Fkmem, (long) nl[N_NPROC].n_value);
  895. X    if (read(Fkmem, (char *) &i_nproc, sizeof i_nproc) != sizeof i_nproc) {
  896. X        fatal("Could not get value of nproc.", FALSE);
  897. X        /*NOTREACHED*/
  898. X    }
  899. X#ifdef DEBUG
  900. X    dprintf("seeking _proc...\n");
  901. X#endif DEBUG
  902. X    memseek(Fkmem, (long) nl[N_PROC].n_value);
  903. X    if (read(Fkmem, (char *) &i_proc, sizeof i_proc) != sizeof i_proc) {
  904. X        fatal("Could not get value of proc.", FALSE);
  905. X        /*NOTREACHED*/
  906. X    }
  907. X#endif
  908. X    mytty = gettyname();
  909. X#ifdef DEBUG
  910. X    dprintf("mytty = '%s'\n", mytty);
  911. X#endif DEBUG
  912. X    
  913. X    if ((list = fopen(CONTROL, "r")) == NULL) {
  914. X        fatal(CONTROL, TRUE);
  915. X        /*NOTREACHED*/
  916. X    }
  917. X
  918. X    if ((user = getlogin()) == NULL) {
  919. X        if ((pw = getpwuid(getuid())) != NULL)
  920. X            user = pw->pw_name;
  921. X        else
  922. X            user = "(unknown)";
  923. X#ifdef DEBUG
  924. X        dprintf("getlogin() failed. user = '%s'\n", user);
  925. X#endif DEBUG
  926. X    }
  927. X#ifdef DEBUG
  928. X        else dprintf("getlogin() succeeded. user = '%s'\n", user);
  929. X#endif DEBUG
  930. X
  931. X    cf = parse(list, game);
  932. X
  933. X#ifdef DEBUG
  934. X    dprintf("game = '%s'\tmax load = '%.2f'\tmax users = '%d'\tpriority = %d\n",
  935. X            cf->cf_game, cf->cf_load, cf->cf_users, cf->cf_priority);
  936. X    dprintf("badttys = '%s'\tfreettys = '%s'\nnofree = %d\tsp_name = '%s'\n", 
  937. X        cf->cf_badttys, cf->cf_freettys, cf->cf_nofreettys, cf->cf_spname);
  938. X    dprintf("tod morn = %d \t even = %d\n", cf->cf_todmorn, cf->cf_todeven);
  939. X#endif DEBUG
  940. X        
  941. X    (void) fclose(list);
  942. X    (void) signal(SIGCHLD, death);
  943. X    (void) signal(SIGINT, SIG_IGN);
  944. X    (void) signal(SIGQUIT, SIG_IGN);
  945. X    (void) signal(SIGTSTP, SIG_IGN);
  946. X}
  947. X
  948. X/*
  949. X * load - Return the 5 minute load average
  950. X */
  951. Xload()
  952. X{
  953. X    (void) lseek(Fkmem, (long)nl[N_AVENRUN].n_value, 0);
  954. X    (void) read(Fkmem, avenrun, sizeof(avenrun));
  955. X    return (was_load = (avenrun[1] >= cf->cf_load));
  956. X}
  957. X
  958. X/*
  959. X * users - Count the number of users logged in.
  960. X */
  961. Xusers()
  962. X{
  963. X    int count = 0;
  964. X
  965. X    (void) lseek(Futmp, (long)0, 0);
  966. X    while (read(Futmp, &buf, sizeof(buf)) > 0) {
  967. X        if (buf.ut_name[0] != '\0') {
  968. X            count++;
  969. X        }
  970. X    }
  971. X    return (was_users = (count > cf->cf_users));
  972. X}
  973. X
  974. X/*
  975. X * tod - Find out if it is okay to play right now.
  976. X */
  977. Xtod()
  978. X{
  979. X    long now;
  980. X    struct tm *localtime();
  981. X    struct tm *ntime;
  982. X
  983. X    if (cf->cf_todmorn == 0 && cf->cf_todeven == 0) {
  984. X#ifdef DEBUG
  985. X        dprintf("tod(): tod not set.\n");
  986. X#endif DEBUG
  987. X        return(was_tod = FALSE);
  988. X    }
  989. X
  990. X    time(&now);
  991. X    ntime = localtime(&now);
  992. X    if(ntime->tm_wday == 0 || ntime->tm_wday == 6)
  993. X        return(was_tod = FALSE);/* OK on Sat & Sun */
  994. X    if(ntime->tm_hour < cf->cf_todmorn || ntime->tm_hour >= cf->cf_todeven)
  995. X        return(was_tod = FALSE);/* OK during non working hours */
  996. X    
  997. X    return(was_tod = TRUE);
  998. X}
  999. X
  1000. Xcheckfor(file)
  1001. Xchar *file;
  1002. X{
  1003. X#ifdef DEBUG
  1004. X    dprintf("checkfor(%s) called\n", file);
  1005. X#endif DEBUG
  1006. X
  1007. X    was_nogames = access(file, R_OK) == 0;
  1008. X#ifdef DEBUG
  1009. X    dprintf("checkfor(): access = %d\n", was_nogames);
  1010. X#endif DEBUG
  1011. X    return(was_nogames);
  1012. X}
  1013. X
  1014. X/*
  1015. X * getaline - Returns the first line from file.
  1016. X */
  1017. Xchar *
  1018. Xgetaline(file)
  1019. Xchar *file;
  1020. X{
  1021. X    char buf[BUFSIZ];
  1022. X    FILE *fd, *fopen();
  1023. X
  1024. X    if((fd = fopen(file, "r")) != NULL) {
  1025. X        fgets(buf, sizeof(buf), fd);
  1026. X        (void) fclose(fd);
  1027. X        return(buf);
  1028. X    }
  1029. X    return(NULL);
  1030. X}
  1031. X
  1032. X/*
  1033. X * freettys - Find out if there are enough free ttys.
  1034. X *        The user invoking a game (under GR) must be on
  1035. X *        one of the ttys listed in cf->cf_freettys for this check.
  1036. X */
  1037. Xfreettys()
  1038. X{
  1039. X    int left = 0;
  1040. X    char *remttys;
  1041. X
  1042. X    remttys = cf->cf_freettys;
  1043. X    if(strlen(remttys) < 2)
  1044. X        return;
  1045. X
  1046. X#ifdef DEBUG
  1047. X    dprintf("freeyttys started. ttys = '%s'\n", remttys);
  1048. X#endif DEBUG
  1049. X
  1050. X    /*
  1051. X     * If you're not on a "special" tty, we don't
  1052. X     * worry about you.
  1053. X     */
  1054. X    if(!sgrep(mytty, remttys)) {
  1055. X#ifdef DEBUG
  1056. X        dprintf("You're NOT on a special tty.\n");
  1057. X#endif DEBUG
  1058. X        return(0);
  1059. X    }
  1060. X
  1061. X#ifdef DEBUG
  1062. X    dprintf("You're on a special tty.\n");
  1063. X#endif DEBUG
  1064. X
  1065. X    (void) lseek(Futmp, (long)0, 0);
  1066. X    while (read(Futmp, &buf, sizeof(buf)) > 0) {
  1067. X        if (buf.ut_name[0] != '\0') {
  1068. X            if(strncmp(buf.ut_line, "tty", 3) == 0)
  1069. X                remttys = deltty(buf.ut_line+3, remttys);
  1070. X        }
  1071. X    }
  1072. X
  1073. X    left = strlen(remttys) / 2;
  1074. X#ifdef DEBUG
  1075. X    dprintf("remaining ttys = '%s' # left = %d\n", remttys, left);
  1076. X#endif DEBUG
  1077. X    return(was_freettys = (left < cf->cf_nofreettys));
  1078. X}
  1079. X
  1080. X/*
  1081. X * deltty - delete a tty "name" from the remaining ttys
  1082. X */
  1083. Xchar *
  1084. Xdeltty(name, list)
  1085. Xchar *name;
  1086. Xchar *list;
  1087. X{
  1088. X    char tmp[BUFSIZ];
  1089. X    register int i;
  1090. X
  1091. X    i = 0;
  1092. X    while(*list) {
  1093. X        if (*list == *name) {
  1094. X            if(*++list == *++name) {
  1095. X                *++list;
  1096. X            } else {
  1097. X                *--list;
  1098. X            }
  1099. X            *--name;
  1100. X        } 
  1101. X        tmp[i++] = *list++;
  1102. X    }
  1103. X    tmp[i] = NULL;
  1104. X    return(tmp);
  1105. X}
  1106. X
  1107. X/*
  1108. X * sgrep(x, str) -- check for x in str.  Return 1 (TRUE) if exists.
  1109. X *            Otherwise 0 (FALSE).
  1110. X */
  1111. X
  1112. Xsgrep(x, str)
  1113. Xchar     *x;
  1114. Xchar     *str;
  1115. X{
  1116. X    if (!str)
  1117. X        return(FALSE);
  1118. X    while(*str) {
  1119. X        if(*str == *x){
  1120. X            if(*++str == *++x) {
  1121. X                return(TRUE);
  1122. X            } else {
  1123. X                *--x;
  1124. X            }
  1125. X        }
  1126. X        *++str;
  1127. X    }
  1128. X    return(FALSE);
  1129. X}
  1130. X
  1131. X/*
  1132. X * badttys - Are we allowed to play games on this tty?
  1133. X */
  1134. Xbadttys()
  1135. X{
  1136. X    if(sgrep(mytty, cf->cf_badttys)) {
  1137. X        badtty = mytty;
  1138. X        return(was_badttys = TRUE);
  1139. X    }
  1140. X    return(was_badttys = FALSE);
  1141. X}
  1142. X
  1143. X/*
  1144. X * gettyname - Determine which tty we're on.
  1145. X *             Returns 2 char string.
  1146. X */
  1147. Xchar *
  1148. Xgettyname()
  1149. X{
  1150. X    char *ttyname();
  1151. X#ifdef FINDTTY
  1152. X    char *findtty();
  1153. X    char *t, *t2;
  1154. X
  1155. X#ifdef DEBUG
  1156. X    dprintf("gettyname(): calling findtty()...\n");
  1157. X#endif DEBUG
  1158. X    t = findtty(getpid());
  1159. X    if (strcmp(t, "co") == 0) {    /* We're probably  using rlogin or telnet */
  1160. X        t2 = ttyname(2)+8;
  1161. X#ifdef DEBUG
  1162. X        dprintf("t2 = '%s'\n", t2);
  1163. X#endif DEBUG
  1164. X        if (strcmp(t, t2)) {     /* there's a difference: so believe ttyname() */
  1165. X#ifdef DEBUG
  1166. X            dprintf("gettyname: difference.  using t2\n");
  1167. X#endif DEBUG
  1168. X            t = t2;
  1169. X        }
  1170. X    }
  1171. X    return(t);
  1172. X#else
  1173. X#ifdef DEBUG
  1174. X    dprintf("gettyname(): using ttyname()...\n");
  1175. X#endif DEBUG
  1176. X    return(ttyname(2)+8);
  1177. X#endif
  1178. X}
  1179. X
  1180. Xfatal(msg, pflag)
  1181. Xchar *msg;
  1182. Xint pflag;
  1183. X{
  1184. X    fprintf(stderr, "%s: ", prog);
  1185. X    if (pflag)
  1186. X        perror(msg);
  1187. X    else
  1188. X        fprintf(stderr, "Fatal Error: %s\n", msg);
  1189. X    exit(1);
  1190. X}
  1191. END_OF_gr.c
  1192. if test 16592 -ne `wc -c <gr.c`; then
  1193.     echo shar: \"gr.c\" unpacked with wrong size!
  1194. fi
  1195. # end of overwriting check
  1196. fi
  1197. if test -f gr.conf -a "${1}" != "-c" ; then 
  1198.   echo shar: Will not over-write existing file \"gr.conf\"
  1199. else
  1200. echo shar: Extracting \"gr.conf\" \(1455 characters\)
  1201. sed "s/^X//" >gr.conf <<'END_OF_gr.conf'
  1202. X#
  1203. X# $Header: gr.conf,v 1.1 86/12/04 13:23:47 mcooper Exp $
  1204. X#
  1205. X# GENERIC Game Regulator Control and Configuration File
  1206. X#
  1207. X#     Name         - Name of game in /usr/games.     (string)
  1208. X#    Load         - Maximum load average.      (floating point)
  1209. X#    Users         - Maximum number of users.      (integer)
  1210. X#    Priority    - Priority game will run at.
  1211. X#              See setpriority(2).        (integer)
  1212. X#
  1213. X# A default for all other games may be set by naming the last 
  1214. X# entry "default".
  1215. X#
  1216. X#         Maximum
  1217. X# Name           Load    Users   Priority
  1218. X#--------------------------------------
  1219. Xrogue        3.5    14    0
  1220. Xarogue        3.5    14    0
  1221. Xurogue        3.5    14    0
  1222. Xhack        3.5    14    5
  1223. Xsail        3.5    14    0
  1224. Xempire        3.5    14    5
  1225. Xdebug        4.2     20     3
  1226. Xtest        5.0    20    3
  1227. Xdefault        4.0    14    0
  1228. X
  1229. X
  1230. XCONFIGURATION
  1231. X#
  1232. X#        ==================================
  1233. X#             Configuration Section
  1234. X#        ==================================
  1235. X#
  1236. X#   Word      Usage                  Default
  1237. X#-----------------------------------------------------------------------
  1238. X# "hidedir"    hidedir dir            /usr/games/.hide
  1239. X# "freettys"    freettys tty_names number    [no default]
  1240. X# "spname"    spname name            [no default]
  1241. X# "badttys"    badttys tty_names        [no default]
  1242. X# "tod"        tod morning evening        [no default]
  1243. X# "logfile"    logfile file            /usr/games/lib/gr.log
  1244. X# "nogames"    nogames file            /usr/games/nogames
  1245. X#-----------------------------------------------------------------------
  1246. X#
  1247. X
  1248. Xfreettys    h2h3h4h5h6h7h8h9hahbhchdhehf     1
  1249. Xspname        Micom
  1250. X
  1251. Xbadttys        h0h1
  1252. Xtod        8    19
  1253. X
  1254. Xhidedir        /usr/games/.hide
  1255. Xlogfile        /usr/games/lib/gr.log
  1256. Xnogames        /usr/games/nogames
  1257. END_OF_gr.conf
  1258. if test 1455 -ne `wc -c <gr.conf`; then
  1259.     echo shar: \"gr.conf\" unpacked with wrong size!
  1260. fi
  1261. # end of overwriting check
  1262. fi
  1263. if test -f gr.conf.5 -a "${1}" != "-c" ; then 
  1264.   echo shar: Will not over-write existing file \"gr.conf.5\"
  1265. else
  1266. echo shar: Extracting \"gr.conf.5\" \(4005 characters\)
  1267. sed "s/^X//" >gr.conf.5 <<'END_OF_gr.conf.5'
  1268. X.\"
  1269. X.\" $Header: gr.conf.5,v 1.1 86/12/17 19:29:15 mcooper Exp $
  1270. X.\"
  1271. X.TH GR.CONF 5 12/17/86
  1272. X.ds ]W USC Computing Services
  1273. X.SH NAME
  1274. Xgr.conf \- Game Regulator control and configuration file
  1275. X.SH DESCRIPTION
  1276. X.I Gr.conf
  1277. Xis 
  1278. Xthe configuration and control file for
  1279. X.I GR.
  1280. XIt is split into two major parts.
  1281. XThe first part contains information on the system conditions on a
  1282. Xper game basis with a provision for a default.
  1283. XThese parameters may need tuning from time to time as system loading
  1284. Xand resources change over a long period of time.
  1285. XThe second part contains configuration
  1286. Xinformation for enabling/disabling certain features of
  1287. X.I GR.
  1288. XThis part should rarely need updating.
  1289. XThe two parts of the control file are seperated by the word
  1290. X.I CONFIGURE
  1291. Xappearing on a line by itself.
  1292. X.PP
  1293. XThe syntax of the first section is as follows:
  1294. Xthe first field is a
  1295. Xgame name (string), 
  1296. Xthe second field is the
  1297. Xmaximum load average (floating point), 
  1298. Xthe third field is the
  1299. Xmaximum users (integer), and
  1300. Xthe fourth and final field is the
  1301. Xpriority (integer) the game should run at (see 
  1302. X.I setpriority(2)).
  1303. XEach field should be seperated
  1304. Xby white space (spaces and/or tabs).  Lines beginning with ``#'' are 
  1305. Xignored.
  1306. XIf the game name (first field) is called 
  1307. X.I default,
  1308. Xthen the other three fields are taken as the default parameters for any
  1309. Xgame not specifically listed.
  1310. XThe
  1311. X.I default
  1312. Xshould be the last game listed.
  1313. XThus, you may specify specific values for a
  1314. Xfew games, with a default for all others.
  1315. X.PP
  1316. XThe second part of the control and configuration file can be used
  1317. Xto set 
  1318. X.I GR
  1319. Xoptions.
  1320. XEach 
  1321. X.I GR
  1322. Xoption is enabled/set with a keyword followed by a set of parameters:
  1323. X.IP "hidedir \fIdirectory\fR"
  1324. X.I directory
  1325. Xis the name of the directory containing the real (hiden) game binaries.
  1326. XThe default is
  1327. X.I /usr/games/.hide
  1328. X.IP "freettys \fIttynames N\fR"
  1329. X.I ttynames
  1330. Xis a list of ttys (last 2 characters only) that there are to be at least
  1331. X.I N
  1332. Xavialable for game playing to be allowed.
  1333. XUseful if you have a limited number of dialup modem ports or such
  1334. Xthat you don't
  1335. Xwant monopolized by game players.
  1336. X.IP "spname \fIname\fR"
  1337. XUse 
  1338. X.I name
  1339. Xto describe what
  1340. X.I freettys
  1341. Xare when printing a message to a user.
  1342. Xi.e. ``Dialup'', ``Micom'', ``Special'', etc.
  1343. X.IP "badttys \fIttynames\fR"
  1344. X.I ttynames
  1345. Xis a list of ttys (last 2 characters only) on which game playing is
  1346. X.B never
  1347. Xpermitted.
  1348. X.IP "tod \fIN M\fR"
  1349. XGame playing is 
  1350. X.B never
  1351. Xpermitted between the hours of
  1352. X.I N
  1353. Xand
  1354. X.I M
  1355. X(24 hour clock format).
  1356. X.IP "logfile \fIfile\fR"
  1357. XLog information concerning game playing to
  1358. X.I file.
  1359. XThe default is
  1360. X.I /usr/games/lib/gr.log.
  1361. X.IP "nogames \fIfile\fR"
  1362. XIf
  1363. X.I file
  1364. Xis present, game playing is not permitted.  The first line of
  1365. Xthe file is used to print a message to the user.
  1366. XUsed to turn game playing on and off.
  1367. XThe default is
  1368. X.I /usr/games/nogames.
  1369. X.PP
  1370. XBelow is a sample file:
  1371. X.nf
  1372. X.sp 1
  1373. X.KS
  1374. X    #
  1375. X    # Game Regulator Control File
  1376. X    #
  1377. X    #
  1378. X    # Control Section
  1379. X    #                   Maximum
  1380. X    # Name            Load    Users      Priority
  1381. X    #\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  1382. X    rogue             4.0      8            0
  1383. X    hack              4.0      8            5
  1384. X    sail              4.0      8            0
  1385. X    empire            4.0      8            0
  1386. X    default           5.0      8            0
  1387. X    
  1388. X    CONFIGURE
  1389. X    #
  1390. X    # Configuration section
  1391. X    #
  1392. X    
  1393. X    # should always be at least 1 of ttyd[0125] avialable
  1394. X    freettys        d0d1d2d5        1
  1395. X    spname          Dialup
  1396. X    
  1397. X    # no games ever on ttyh[01]
  1398. X    badttys            h0h1
  1399. X    
  1400. X    # no games from 800 hours to 1900 hours
  1401. X    tod             8       19
  1402. X    
  1403. X    hidedir            /usr/games/.hide
  1404. X    logfile            /usr/games/lib/gr.log
  1405. X    nogames            /usr/games/nogames
  1406. X.KE
  1407. X.fi
  1408. X.SH AUTHOR
  1409. XMichael A. Cooper (mcooper@oberon.USC.EDU)
  1410. X.br
  1411. XUSC Computing Services
  1412. X.SH FILES
  1413. X/usr/games/lib/gr.conf
  1414. X.SH SEE ALSO
  1415. Xgr(8), setpriority(2),
  1416. X.br
  1417. XSection 6 of the UNIX Programmer's Manual.
  1418. END_OF_gr.conf.5
  1419. if test 4005 -ne `wc -c <gr.conf.5`; then
  1420.     echo shar: \"gr.conf.5\" unpacked with wrong size!
  1421. fi
  1422. # end of overwriting check
  1423. fi
  1424. if test -f gr.h -a "${1}" != "-c" ; then 
  1425.   echo shar: Will not over-write existing file \"gr.h\"
  1426. else
  1427. echo shar: Extracting \"gr.h\" \(3671 characters\)
  1428. sed "s/^X//" >gr.h <<'END_OF_gr.h'
  1429. X/*
  1430. X * $Header: gr.h,v 1.14 86/12/17 19:25:02 mcooper Exp $
  1431. X *------------------------------------------------------------------
  1432. X *
  1433. X * $Source: /big/src/usc/bin/gr/RCS/gr.h,v $
  1434. X * $Revision: 1.14 $
  1435. X * $Date: 86/12/17 19:25:02 $
  1436. X * $State: Exp $
  1437. X * $Author: mcooper $
  1438. X * $Locker:  $
  1439. X *
  1440. X *------------------------------------------------------------------
  1441. X *
  1442. X * Michael A. Cooper (mcooper@oberon.USC.EDU)
  1443. X * University Computing Services,
  1444. X * University of Southern California
  1445. X *
  1446. X *------------------------------------------------------------------
  1447. X * $Log:    gr.h,v $
  1448. X * Revision 1.14  86/12/17  19:25:02  mcooper
  1449. X * Config file is now called "gr.conf".
  1450. X * 
  1451. X * Revision 1.13  86/12/02  19:50:43  mcooper
  1452. X * Removed all references to FINDTTY
  1453. X * since findtty.c is not being distributed.
  1454. X * 
  1455. X * Revision 1.12  86/11/07  19:23:21  mcooper
  1456. X * If BSD42 is defined (from Makefile), then we
  1457. X * define FINDTTY.  This file should no longer need
  1458. X * tweaking by people installing gr.
  1459. X * 
  1460. X * Revision 1.11  86/07/17  15:22:39  mcooper
  1461. X * Bumped MAXTTYS to 120 for portability to
  1462. X * other UCS machines.
  1463. X * 
  1464. X * Revision 1.10  86/07/14  15:54:47  mcooper
  1465. X * Moved most of the compile time configuration
  1466. X * options to the control file.
  1467. X * 
  1468. X * Revision 1.9  86/07/03  14:27:44  mcooper
  1469. X * - Major work on "special" ttys.  
  1470. X *   - Bug fix in deltty().
  1471. X *   - Changed are #define macros.
  1472. X *   - Added findtty() (in findtty.c) to try and
  1473. X *     determine the users real tty.  (4.2bsd)
  1474. X * - Added debug mode.
  1475. X * - Misc. - Can't remember them all.
  1476. X * 
  1477. X * Revision 1.8  86/06/18  13:47:58  mcooper
  1478. X * Implemented BAD_TTYS - Check to see if
  1479. X * the user is on a BAD_TTYS.  If so, game
  1480. X * playing is not permited at all.  Also
  1481. X * cleaned up #ifdef TOD stuff.
  1482. X * 
  1483. X * Revision 1.7  86/06/04  12:21:55  mcooper
  1484. X * Use SP_NAME for name of special ttys when
  1485. X * printing messages to the user.
  1486. X * 
  1487. X * Revision 1.6  86/06/02  13:32:20  mcooper
  1488. X * More cleanup on SP_TTYS.
  1489. X * 
  1490. X * Revision 1.5  86/05/30  21:34:05  mcooper
  1491. X * Added support for "special" ttys.  i.e. only a limited
  1492. X * number of SP_TTYS.
  1493. X * 
  1494. X * Revision 1.4  86/05/14  16:09:17  mcooper
  1495. X * Cleaned up and somewhat de-linted.
  1496. X * 
  1497. X * Revision 1.3  86/03/25  15:50:31  mcooper
  1498. X * Moved CONTROL back to normal place in /usr/games/lib.
  1499. X * 
  1500. X * Revision 1.2  86/03/25  15:47:57  mcooper
  1501. X * Lines beginning with '#' are comment lines.
  1502. X * 
  1503. X * Revision 1.1  86/02/12  17:49:54  mcooper
  1504. X * Initial revision
  1505. X * 
  1506. X *------------------------------------------------------------------
  1507. X */
  1508. X
  1509. X/*
  1510. X * CONTROL - Master control file.
  1511. X */
  1512. X#ifndef DEBUG
  1513. X# define CONTROL        "/usr/games/lib/gr.conf"
  1514. X#else
  1515. X# define CONTROL        "gr.conf"
  1516. X#endif
  1517. X
  1518. X/* 
  1519. X * MAXTTYS - The maximum number of tty?? in /dev.
  1520. X *          Only used with FINDTTY.
  1521. X */
  1522. X#define MAXTTYS    120
  1523. X
  1524. X
  1525. X/*
  1526. X * Misc. defines - Leave this alone!
  1527. X */
  1528. X#define TRUE        1
  1529. X#define FALSE        0
  1530. X#define COMMENT        '#'
  1531. X#define SLEEPTIME    60        /* sleep interval */
  1532. X#define dprintf        if (debug) printf
  1533. X
  1534. X#define CFBUF        256
  1535. X
  1536. Xstruct cfinfo {
  1537. X    char     cf_game[CFBUF];        /* name of the game */
  1538. X    double     cf_load;            /* max load average */
  1539. X    int     cf_users;            /* max users */
  1540. X    int     cf_priority;        /* game priority (setpriority(2)) */
  1541. X    char     cf_badttys[CFBUF];    /* ttys game playing not permitted on */
  1542. X    char     cf_freettys[CFBUF];    /* list of ttys to watch */
  1543. X    int     cf_nofreettys;        /* number of freettys must be open */
  1544. X    char     cf_spname[CFBUF];    /* name to use for freettys */
  1545. X    int     cf_todmorn;            /* hour of morning for games off */
  1546. X    int     cf_todeven;            /* hour of evening for games on */
  1547. X    char    cf_hidedir[CFBUF];    /* directory containing the real games */
  1548. X    char    cf_logfile[CFBUF];    /* file to log info to */
  1549. X    char    cf_nogames[CFBUF];    /* file that says no games */
  1550. X};
  1551. X
  1552. END_OF_gr.h
  1553. if test 3671 -ne `wc -c <gr.h`; then
  1554.     echo shar: \"gr.h\" unpacked with wrong size!
  1555. fi
  1556. # end of overwriting check
  1557. fi
  1558. if test -f logfile.c -a "${1}" != "-c" ; then 
  1559.   echo shar: Will not over-write existing file \"logfile.c\"
  1560. else
  1561. echo shar: Extracting \"logfile.c\" \(1761 characters\)
  1562. sed "s/^X//" >logfile.c <<'END_OF_logfile.c'
  1563. X#ifndef lint
  1564. Xstatic char *RCSid = "$Header: logfile.c,v 1.7 86/12/02 20:27:42 mcooper Locked $";
  1565. X#endif
  1566. X
  1567. X/*
  1568. X *------------------------------------------------------------------
  1569. X *
  1570. X * $Source: /big/src/usc/bin/gr/RCS/logfile.c,v $
  1571. X * $Revision: 1.7 $
  1572. X * $Date: 86/12/02 20:27:42 $
  1573. X * $State: Exp $
  1574. X * $Author: mcooper $
  1575. X * $Locker: mcooper $
  1576. X *
  1577. X *------------------------------------------------------------------
  1578. X *
  1579. X * Michael Cooper (mcooper@oberon.USC.EDU)
  1580. X * University Computing Services,
  1581. X * University of Southern California,
  1582. X * Los Angeles, California,   90089-0251
  1583. X * (213) 743-3469
  1584. X *
  1585. X *------------------------------------------------------------------
  1586. X * $Log:    logfile.c,v $
  1587. X * Revision 1.7  86/12/02  20:27:42  mcooper
  1588. X * "#ifdef DEBUG"'s all dprintf's.
  1589. X * 
  1590. X * Revision 1.6  86/07/15  14:54:18  mcooper
  1591. X * Determine user name in setup() instead of
  1592. X * everytime logfile() is called.
  1593. X * 
  1594. X * Revision 1.5  86/07/14  15:54:42  mcooper
  1595. X * Moved most of the compile time configuration
  1596. X * options to the control file.
  1597. X * 
  1598. X * Revision 1.4  86/05/14  16:29:12  mcooper
  1599. X * Somewhat de-linted.
  1600. X * 
  1601. X * Revision 1.3  86/03/25  15:44:35  mcooper
  1602. X * more of same.
  1603. X * 
  1604. X * Revision 1.2  86/03/25  15:35:43  mcooper
  1605. X * New headers...
  1606. X * 
  1607. X *------------------------------------------------------------------
  1608. X */
  1609. X
  1610. X
  1611. X#include <stdio.h>
  1612. X#include "gr.h"
  1613. X
  1614. Xextern int debug;
  1615. Xextern char *user;
  1616. Xextern char *mytty;
  1617. X
  1618. Xlogfile(msg, file)
  1619. Xchar *msg;
  1620. Xchar *file;
  1621. X{
  1622. X    char *ctime();
  1623. X    double now;
  1624. X    FILE *fd, *fopen();
  1625. X
  1626. X    (void) time(&now);
  1627. X
  1628. X#ifdef DEBUG
  1629. X    dprintf("logfile(): user = '%s' tty = '%s'\n", user, mytty);
  1630. X#endif DEBUG
  1631. X
  1632. X    if((fd = fopen(file, "a")) != NULL){
  1633. X        (void) fprintf(fd, "%-9s tty%-3s %10.24s  [ %s ]\n", 
  1634. X                user, mytty, ctime(&now), msg);
  1635. X        (void) fclose(fd);
  1636. X    }
  1637. X}
  1638. END_OF_logfile.c
  1639. if test 1761 -ne `wc -c <logfile.c`; then
  1640.     echo shar: \"logfile.c\" unpacked with wrong size!
  1641. fi
  1642. # end of overwriting check
  1643. fi
  1644. if test -f parse.c -a "${1}" != "-c" ; then 
  1645.   echo shar: Will not over-write existing file \"parse.c\"
  1646. else
  1647. echo shar: Extracting \"parse.c\" \(3910 characters\)
  1648. sed "s/^X//" >parse.c <<'END_OF_parse.c'
  1649. X#ifndef lint
  1650. Xstatic char *RCSid = "$Header: parse.c,v 1.5 86/12/02 20:28:02 mcooper Locked $";
  1651. X#endif
  1652. X
  1653. X/*
  1654. X *------------------------------------------------------------------
  1655. X *
  1656. X * $Source: /big/src/usc/bin/gr/RCS/parse.c,v $
  1657. X * $Revision: 1.5 $
  1658. X * $Date: 86/12/02 20:28:02 $
  1659. X * $State: Exp $
  1660. X * $Author: mcooper $
  1661. X * $Locker: mcooper $
  1662. X *
  1663. X *------------------------------------------------------------------
  1664. X *
  1665. X * Michael A. Cooper
  1666. X * University Computing Services, 
  1667. X * University of Southern California
  1668. X * (mcooper@oberon.USC.EDU)
  1669. X *
  1670. X *------------------------------------------------------------------
  1671. X * $Log:    parse.c,v $
  1672. X * Revision 1.5  86/12/02  20:28:02  mcooper
  1673. X * "#ifdef DEBUG"'s all dprintf's.
  1674. X * 
  1675. X * Revision 1.4  86/07/17  16:15:45  mcooper
  1676. X * All fatal errors now use fatal().
  1677. X * 
  1678. X * Revision 1.3  86/07/14  16:00:40  mcooper
  1679. X * - Don't setup default logfile.
  1680. X * - Mostly de-linted.
  1681. X * 
  1682. X * Revision 1.2  86/07/14  15:55:30  mcooper
  1683. X * Added rcs headers.
  1684. X * 
  1685. X *------------------------------------------------------------------
  1686. X */
  1687. X
  1688. X#include <stdio.h>
  1689. X#include "gr.h"
  1690. X
  1691. Xextern int debug;
  1692. X
  1693. Xstruct cfinfo *
  1694. Xparse(fd, game)
  1695. XFILE *fd;
  1696. Xchar *game;
  1697. X{
  1698. X    char lbuf[BUFSIZ], tmp[3][BUFSIZ];
  1699. X    int config = FALSE;
  1700. X    int foundname = FALSE;
  1701. X    struct cfinfo cf;
  1702. X    
  1703. X    /*
  1704. X     * setup some defaults
  1705. X     */
  1706. X    cf.cf_nofreettys = 2;
  1707. X    cf.cf_load = 4.0;
  1708. X    cf.cf_users = 8;
  1709. X    (void) strcpy(cf.cf_spname, "Special");
  1710. X    (void) strcpy(cf.cf_hidedir, "/usr/games/.hide");
  1711. X    (void) strcpy(cf.cf_nogames, "/usr/games/nogames");
  1712. X
  1713. X    while (fgets(lbuf, sizeof(lbuf), fd)) {
  1714. X        if (lbuf[0] == COMMENT || lbuf[0] == '\n')
  1715. X            continue;
  1716. X
  1717. X        tmp[0][0] = NULL;
  1718. X        tmp[1][0] = NULL;
  1719. X        tmp[2][0] = NULL;
  1720. X
  1721. X        (void) sscanf(lbuf, "%s%s%s", tmp[0], tmp[1], tmp[2]);
  1722. X#ifdef DEBUG
  1723. X        dprintf("tmp[0] = '%s' tmp[1] = '%s' tmp[2] = '%s'\n", 
  1724. X            tmp[0], tmp[1], tmp[2]);
  1725. X#endif DEBUG
  1726. X
  1727. X        if (strncmp(tmp[0], "CONFIG", 6) == 0) {
  1728. X            config = TRUE;
  1729. X#ifdef DEBUG
  1730. X            dprintf("found config\n");
  1731. X#endif DEBUG
  1732. X            continue;
  1733. X        }
  1734. X
  1735. X        if (config) {
  1736. X            if (strncmp(tmp[0], "badttys", 7) == 0) {
  1737. X                (void) strcpy(cf.cf_badttys, tmp[1]);
  1738. X            }
  1739. X            else if (strncmp(tmp[0], "freettys", 8) == 0) {
  1740. X                (void) strcpy(cf.cf_freettys, tmp[1]);
  1741. X                cf.cf_nofreettys = atoi(tmp[2]);
  1742. X            }
  1743. X            else if (strncmp(tmp[0], "spname", 6) == 0) {
  1744. X                (void) strcpy(cf.cf_spname, tmp[1]);
  1745. X            }
  1746. X            else if (strncmp(tmp[0], "tod", 3) == 0) {
  1747. X                cf.cf_todmorn = atoi(tmp[1]);
  1748. X                cf.cf_todeven = atoi(tmp[2]);
  1749. X            }
  1750. X            else if (strncmp(tmp[0], "debug", 5) == 0) {
  1751. X                if (strcmp(tmp[1], "on") == 0) 
  1752. X                    debug = TRUE;
  1753. X                else
  1754. X                    debug = FALSE;
  1755. X            }
  1756. X            else if (strncmp(tmp[0], "hidedir", 7) == 0) {
  1757. X                if(tmp[1][0] == NULL) {
  1758. X                    fatal("No hiden directory defined.");
  1759. X                    /*NOTREACHED*/
  1760. X                }
  1761. X                (void) strcpy(cf.cf_hidedir, tmp[1]);
  1762. X            }
  1763. X            else if (strncmp(tmp[0], "nogames", 7) == 0) {
  1764. X                (void) strcpy(cf.cf_nogames, tmp[1]);
  1765. X            }
  1766. X            else if (strncmp(tmp[0], "logfile", 7) == 0) {
  1767. X                if(tmp[1][0] == NULL) {
  1768. X                    fatal("Keyword \"logfile\" set, but not defined.");
  1769. X                    /*NOTREACHED*/
  1770. X                }
  1771. X                (void) strcpy(cf.cf_logfile, tmp[1]);
  1772. X            }
  1773. X            continue;
  1774. X        } else if (!foundname) {
  1775. X            if ((strcmp(tmp[0], game) == 0)||(strcmp(tmp[0],"default") == 0)){
  1776. X#ifdef DEBUG
  1777. X                dprintf("parse: found game name\n");
  1778. X#endif DEBUG
  1779. X                foundname = TRUE;
  1780. X                (void) sscanf(lbuf, "%s%lf%d%d", 
  1781. X                    cf.cf_game, &cf.cf_load, &cf.cf_users, &cf.cf_priority);
  1782. X            } 
  1783. X#ifdef DEBUG
  1784. X            else dprintf("word = '%s'\n");
  1785. X#endif DEBUG
  1786. X        }
  1787. X    }
  1788. X#ifdef DEBUG
  1789. X    dprintf("\nCF: game = '%s' load = %.2f users = %d prio = %d\n", 
  1790. X        cf.cf_game, cf.cf_load, cf.cf_users, cf.cf_priority);
  1791. X    dprintf("cf_badttys = '%s' cf_free = '%s' \ncf_nofree = %d\n\n",
  1792. X        cf.cf_badttys, cf.cf_freettys, cf.cf_nofreettys);
  1793. X    dprintf("cf_hidedir = '%s' cf_nogames = '%s'\ncf_logfile = '%s'\n",
  1794. X        cf.cf_hidedir, cf.cf_nogames, cf.cf_logfile);
  1795. X    dprintf("cf_spname = '%s'\n", cf.cf_spname);
  1796. X    dprintf("debug is %d\n", debug);
  1797. X#endif DEBUG
  1798. X    return(&cf);
  1799. X}
  1800. END_OF_parse.c
  1801. if test 3910 -ne `wc -c <parse.c`; then
  1802.     echo shar: \"parse.c\" unpacked with wrong size!
  1803. fi
  1804. # end of overwriting check
  1805. fi
  1806. echo shar: End of archive 1 \(of 1\).
  1807. cp /dev/null ark1isdone
  1808. MISSING=""
  1809. for I in 1 ; do
  1810.     if test ! -f ark${I}isdone ; then
  1811.     MISSING="${MISSING} ${I}"
  1812.     fi
  1813. done
  1814. if test "${MISSING}" = "" ; then
  1815.     echo You have unpacked all 1 archives.
  1816.     rm -f ark[1-9]isdone
  1817. else
  1818.     echo You still need to unpack the following archives:
  1819.     echo "        " ${MISSING}
  1820. fi
  1821. ##  End of shell archive.
  1822. exit 0
  1823.